<?php
namespace app\api\controller\newfile;

use think\Request;
use app\common\model\newmodel\Device as DeviceModel;
use app\common\model\newmodel\Accessories as AccessoriesModel;
use app\common\model\newmodel\AccessorySku as AccessorySkuModel;
use app\common\model\power\Rolepower;
use app\common\model\newmodel\User as UserModel;
use app\api\controller\Pub;
use app\api\controller\Base;

class Accessorysku extends Base
{
    public function initialize(){
		parent::initialize();
		self::is_login();
		Rolepower::powerguard(201201);
	}

    /**
	 * 判断账号是否登录
	 * @return boolean [description]
	 */
	private function is_login(){
		$data = UserModel::is_sessionlogin();
		if (!$data['code']) {
			$data['options'] = 'relogin';
			json($data)->send();
			exit;
		}
	}
    
	/**
     * 添加规格
     */
    public function skuValueAdd()
    {
        $data=input();
        $result = AccessorySkuModel::valueAdd($data);
        return json($result);
    }

    /**
     * 修改规格
     */
    public function skuValueEdit()
    {
        $data = input('post.');
        $result = AccessorySkuModel::valueEdit($data);
        return json($result);
    }

    /**
     * 删除规格
     */
    public function skuValueDel()
    {
        $accessorySku_id = input('id');
        $result = AccessorySkuModel::valueDel($accessorySku_id);
        return json($result);
    }
}